package equals1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-03
 * Time: 9:13
 */
class Person{
    public String id;

    public Person(String id) {
        this.id = id;
        }
    public boolean equals(Object obj){
        if (obj == null){
            return false;
        }else if(obj == this){
            return true;
        }else if(!(obj instanceof Person)){
            return false;
        }
        Person tmp=(Person)obj;
        return this.id.equals(tmp.id);
    }
}
class Student{

}
public class Test {
    public static void main(String[] args) {
        Person person = new Person("123");
        Person person1 = new Person("123");
        System.out.println(person.equals(null));
    }
    public static void main3(String[] args) {
        Person person = new Person("123");
        Student student = new Student();
        System.out.println(person.equals(student));
    }
    public static void main2(String[] args) {
        Person person = new Person("123");
        Person person1 = person;
        System.out.println(person.equals(person1));
    }
    public static void main1(String[] args) {
        Person person = new Person("123");
        Person person1 = new Person("123");
        System.out.println(person==person1);
        System.out.println(person.equals(person1));
    }
}
